//
//  PicTableViewCell.m
//  UI_APP_Project_Bean
//
//  Created by dllo on 16/6/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "PicTableViewCell.h"

#import "ActivityModel.h"
#import "OwnerModel.h"
@interface PicTableViewCell ()

@property(nonatomic, retain)UILabel *titleLabel;
@property(nonatomic, retain)UILabel *timeLabel;
@property(nonatomic, retain)UILabel *nameLabel;
@property(nonatomic, retain)UILabel *typeLabel;
@property(nonatomic, retain)UILabel *addressLabel;
@property(nonatomic, retain)UIImageView *picImageView;

@property(nonatomic, retain)UIImageView *time;
@property(nonatomic, retain)UIImageView *ower;
@property(nonatomic, retain)UIImageView *type;
@property(nonatomic, retain)UIImageView *addre;
@property(nonatomic, retain)UILabel *activ;

@end




@implementation PicTableViewCell
-(void)dealloc{

    [_nameModel release];
    [_picModel release];
    [_titleLabel release];
    [_timeLabel release];
    [_nameLabel release];
    [_typeLabel release];
    [_addressLabel release];
    [_picImageView release];
    
    [_time release];
    [_ower release];
    [_type release];
    [_addre release];
    [_activ release];
    

    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont systemFontOfSize:22];
        self.titleLabel.numberOfLines = 2;
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        
        self.picImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:_picImageView];
        [_picImageView release];
        
        self.time = [[UIImageView alloc]init];
        [self.contentView addSubview:_time];
        [_time release];
        
        self.timeLabel = [[UILabel alloc]init];
        self.timeLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_timeLabel];
        [_timeLabel release];
        
        self.ower = [[UIImageView alloc]init];
        [self.contentView addSubview:_ower];
        [_ower release];

        
        
        self.nameLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];
        
        
        self.type = [[UIImageView alloc]init];
        [self.contentView addSubview:_type];
        [_type release];
        
        
        self.typeLabel = [[UILabel alloc]init];
        self.typeLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_typeLabel];
        [_typeLabel release];
        
        
        
        self.addre = [[UIImageView alloc]init];
        [self.contentView addSubview:_addre];
        [_addre release];
        
        
        self.addressLabel = [[UILabel alloc]init];
        self.addressLabel.font = [UIFont systemFontOfSize:15];
        self.addressLabel.numberOfLines = 2;
        [self.contentView addSubview:_addressLabel];
        [_addressLabel release];
        
        
        self.activ = [[UILabel alloc]init];
        _activ.font = [UIFont systemFontOfSize:24];
        [self.contentView addSubview:_activ];
        [_activ release];
        
        
        
        
        
        
    }
    
    return self;
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.titleLabel.frame =CGRectMake(15, 0, CGRectGetWidth(self.bounds) - 30, 60);
    
    self.picImageView.frame =CGRectMake(15, _titleLabel.frame.size.height + 5, 130, 180);
    
   self.time.frame =CGRectMake(_picImageView.frame.size.width + 20, _picImageView.frame.origin.y, 25, 25);
    self.time.image = [UIImage imageNamed:@"icon_date_blue@2x.png"];


    self.timeLabel.frame =CGRectMake(_time.frame.origin.x + 25, _time.frame.origin.y, 190, _time.frame.size.height);
    
    self.ower.frame = CGRectMake(_time.frame.origin.x, _time.frame.origin.y + _time.frame.size.height + 5, _time.frame.size.width, _time.frame.size.height);
    self.ower.image = [UIImage imageNamed:@"icon_sponsor_blue@2x.png"];
    
    self.nameLabel.frame =CGRectMake(_timeLabel.frame.origin.x, _timeLabel.frame.origin.y + _timeLabel.frame.size.height + 5, _timeLabel.frame.size.width, _timeLabel.frame.size.height);
    
    self.type.frame =CGRectMake(_ower.frame.origin.x, _ower.frame.origin.y + _ower.frame.size.height + 5, _ower.frame.size.width, _ower.frame.size.height);
    self.type.image = [UIImage imageNamed:@"icon_catalog_blue@2x"];
   

    self.typeLabel.frame= CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 5, _nameLabel.frame.size.width, _nameLabel.frame.size.height);
    
    
    self.addre.frame =CGRectMake(_type.frame.origin.x, _type.frame.origin.y +_type.frame.size.height + 5, _type.frame.size.width, _type.frame.size.height);
    _addre.image = [UIImage imageNamed:@"icon_spot_blue@2x.png"];
    
    self.addressLabel.frame =CGRectMake(_typeLabel.frame.origin.x, _typeLabel.frame.origin.y + _typeLabel.frame.size.height + 1, _typeLabel.frame.size.width, _typeLabel.frame.size.height + 30);
    self.addressLabel.numberOfLines = 3;
 
    
    
    self.activ.frame = CGRectMake(_picImageView.frame.origin.x, _picImageView.frame.origin.y + _picImageView.frame.size.height + 5, 200, 40);
    self.activ.text = @"活动介绍";
    _activ.font = [UIFont systemFontOfSize:24];
   

}

-(void)setPicModel:(ActivityModel *)picModel{

    
    if (_picModel != picModel) {
        [_picModel release];
        _picModel = [picModel retain];
    }
    
    self.titleLabel.text = picModel.title;
    
    //  时间显示处理
    NSString *beginTime = [NSString stringWithFormat:@"%@", [picModel.begin_time substringWithRange:NSMakeRange(5, 11)]];
    NSString *engTime = [NSString stringWithFormat:@"%@", [picModel.end_time substringWithRange:NSMakeRange(5, 11)]];
    self.timeLabel.text = [NSString stringWithFormat:@"%@--%@", beginTime, engTime];
    
    
    self.typeLabel.text = [NSString stringWithFormat:@"类型: %@", picModel.category_name];
    self.addressLabel.text = picModel.address;
   
    self.picImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.picModel.image_hlarge]]];

    
}

-(void)setNameModel:(OwnerModel *)nameModel{
    if (_nameModel != nameModel) {
        [_nameModel release];
        _nameModel = [nameModel retain];
    }
    self.nameLabel.text = nameModel.name;
    
}
    
    
    
    


@end
